package com.cw.jeeyt.service.converter.facade;

import java.util.List;

import com.cw.jeeyt.service.bo.facade.FacadeProjectBo;
import com.cw.jeeyt.dao.model.facade.FacadeProjectDo;
import com.cw.lang.common.utils.CollectionUtil;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;

/**
 * 项目信息转换类
 *
 * @author chenw
 * @date 2019-11-02 14:16:40
 */
public class FacadeProjectConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static FacadeProjectBo do2Bo(FacadeProjectDo model) {
        if (model == null) {
            return null;
        }
        return FacadeProjectBo.builder()
            .id(model.getId())
            .projectCode(model.getProjectCode())
            .projectName(model.getProjectName())
            .docPath(model.getDocPath())
            .projectComment(model.getProjectComment())
            .createBy(model.getCreateBy())
            .createDate(model.getCreateDate())
            .updateBy(model.getUpdateBy())
            .updateDate(model.getUpdateDate())
            .build();
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static FacadeProjectDo bo2Do(FacadeProjectBo bo) {
        if (bo == null) {
            return null;
        }
        FacadeProjectDo model = new FacadeProjectDo();
        model.setId(bo.getId());
        model.setProjectCode(bo.getProjectCode());
        model.setProjectName(bo.getProjectName());
        model.setDocPath(bo.getDocPath());
        model.setProjectComment(bo.getProjectComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<FacadeProjectBo> doList2BoList(List<FacadeProjectDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return null;
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(),FacadeProjectConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<FacadeProjectDo> boList2DoList(List<FacadeProjectBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return null;
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(),FacadeProjectConverter::bo2Do));
    }
}
